package com.easyaccount.interceptor;

import com.easyaccount.bean.LoginUser;
import com.easyaccount.exception.BizException;
import com.easyaccount.model.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class AdminIntercptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {

        HttpSession session = request.getSession();
        LoginUser user = (LoginUser) session.getAttribute("user");
        String id = request.getParameter("id");
        if(user != null){
//            if(id.equals("1")){
//                throw new BizException("不能操作管理员",444);
//            }
            return true;
        }

        return false;
    }
}
